import { IPSDEFormDetail } from './ipsdeform-detail';
import { IPSDEFormGroupBase } from './ipsdeform-group-base';
import { PSDEFormDetailImpl } from './psdeform-detail-impl';
import { IPSLayout } from '../layout/ipslayout';
import { IPSLayoutContainer } from '../layout/ipslayout-container';

export class PSDEFormBaseGroupPanelImpl extends PSDEFormDetailImpl implements IPSLayoutContainer, IPSDEFormGroupBase {
  get captionItemName(): string {
    return this.M.captionItemName;
  }

  get itemIgnoreInput(): number {
    return this.M.itemIgnoreInput != null ? this.M.itemIgnoreInput : 0;
  }

  protected psdeformdetails: IPSDEFormDetail[] | null = null;

  getPSDEFormDetails(): IPSDEFormDetail[] | null {
    if (this.psdeformdetails == null) {
      this.psdeformdetails = this.fillChildListModel(this.M.getPSDEFormDetails, 'control.form.IPSDEFormDetail') as IPSDEFormDetail[];
    }
    return this.psdeformdetails;
  }

  get psDEFormDetails(): IPSDEFormDetail[] | null {
    return this.getPSDEFormDetails();
  }

  findPSDEFormDetail(objKey: any): IPSDEFormDetail | null {
    return this.getPSModel5('control.form.IPSDEFormDetail', this.getPSDEFormDetails(), objKey) as IPSDEFormDetail;
  }

  protected pslayout: IPSLayout | null = null;

  getPSLayout(): IPSLayout | null {
    if (this.pslayout != null) return this.pslayout;
    const value = this.M.getPSLayout;
    if (value == null) {
      return null;
    }
    this.pslayout = this.getPSModel4('control.layout.IPSLayout', value, 'getPSLayout') as IPSLayout;
    return this.pslayout;
  }

  get psLayout(): IPSLayout | null {
    return this.getPSLayout();
  }

  getPSLayoutMust(): IPSLayout {
    const value = this.getPSLayout();
    if (value == null) {
      throw new Error('未指定布局设置');
    }
    return value;
  }

  get subCaption(): string {
    return this.M.subCaption;
  }

  get titleBarCloseMode(): 0 | 1 | 2 {
    return this.M.titleBarCloseMode != null ? this.M.titleBarCloseMode : 0;
  }

  get enableAnchor(): boolean {
    return this.M.enableAnchor != null ? this.M.enableAnchor : false;
  }

  get hideEmptyItems(): boolean {
    return this.M.hideEmptyItems != null ? this.M.hideEmptyItems : false;
  }

  get infoGroupMode(): boolean {
    return this.M.infoGroupMode;
  }

  get cls(): string {
    return 'PSDEFormBaseGroupPanelImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.form.IPSDEFormGroupBase' || cls == 'control.layout.IPSLayoutContainer') return true;
    return super.instanceof(cls);
  }
}
